{% extends "base_generic.html" %}

{% block title %}{% if object %}Edit Author{% else %}Create Author{% endif %}{% endblock %}

{% block content %}
<div class="row">
    <div class="col-md-6">
        <div class="panel panel-default">
            <div class="panel-heading">
                <h3 class="panel-title">
                    {% if object %}Edit Author: {{ object.first_name }} {{ object.last_name }}{% else %}Create New Author{% endif %}
                </h3>
            </div>
            <div class="panel-body">
                <form method="post">
                    {% csrf_token %}
                    
                    <div class="form-group">
                        <label for="{{ form.first_name.id_for_label }}">First Name:</label>
                        {{ form.first_name }}
                        {% if form.first_name.errors %}
                            <div class="text-danger">{{ form.first_name.errors }}</div>
                        {% endif %}
                    </div>
                    
                    <div class="form-group">
                        <label for="{{ form.last_name.id_for_label }}">Last Name:</label>
                        {{ form.last_name }}
                        {% if form.last_name.errors %}
                            <div class="text-danger">{{ form.last_name.errors }}</div>
                        {% endif %}
                    </div>
                    
                    <div class="form-group">
                        <label for="{{ form.date_of_birth.id_for_label }}">Date of Birth:</label>
                        {{ form.date_of_birth }}
                        {% if form.date_of_birth.errors %}
                            <div class="text-danger">{{ form.date_of_birth.errors }}</div>
                        {% endif %}
                    </div>
                    
                    <div class="form-group">
                        <label for="{{ form.date_of_death.id_for_label }}">Date of Death:</label>
                        {{ form.date_of_death }}
                        {% if form.date_of_death.errors %}
                            <div class="text-danger">{{ form.date_of_death.errors }}</div>
                        {% endif %}
                    </div>
                    
                    <div class="form-group">
                        <button type="submit" class="btn btn-primary">
                            {% if object %}Update Author{% else %}Create Author{% endif %}
                        </button>
                        <a href="{% if object %}{{ object.get_absolute_url }}{% else %}{% url 'authors' %}{% endif %}" class="btn btn-default">Cancel</a>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
{% endblock %} 